<!DOCTYPE html>
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<meta name="viewport" content="user-scalable=no, initial-scale=1.0, maximum-scale=1.0, width=device-width">
	<meta name="apple-mobile-web-app-capable" content="yes">
	<meta content="black" name="apple-mobile-web-app-status-bar-style">
	<meta name="format-detection" content="telephone=no">
	<meta content="telephone=no" name="format-detection">
	<meta http-equiv="X-UA-Compatible" content="chrome=1,IE=edge" />
	<link rel="stylesheet" media="screen and (max-width:900px)" href="/assets/stylesheets/style_wap.css" type="text/css" />
	<link rel="stylesheet" media="screen and (min-width:900px)" href="/assets/stylesheets/style_pc.css" type="text/css" />
	<script language="javascript" src="js/organization.js"></script>
	<style type="text/css">
.OrgBox{
	font-size:12px;
	padding:1px 5px ;
	clear:left;
	float:left;
	text-align:center;
	position:absolute;
	width:80px;
	height:126px;
	line-height: 18px;
}
.OrgBox img{
	width:60px;
	height:70px;
	border:1px #bfbfbf solid;
}
.OrgBox div{
	color:#FFA500;
	font-weight:800;
}
.OrgBox .agentName{
	color:red;
}
agentName
</style>
	<title>我的团队</title>
</head>
<body>
	<div class="topline" id="J_topline" data-test="1">
		<nav th:replace="hjh/include::menuV"></nav>
	</div>
	<div class="vipreg tixian content team">
		<p class="fgtil">安置图
		<span style="font-size:14px;">
		&nbsp;&nbsp;左区业绩：<span th:text="${leftGroupInfo.amount}"></span>元
		&nbsp;&nbsp;右区业绩：<span th:text="${rightGroupInfo.amount}"></span>元
		</span>
		<span style="font-size:12px;">
		&nbsp;&nbsp;<img src="/assets/images/icon_putong.png"/>普通会员
		<img src="/assets/images/icon_jinka.png"/>金卡会员
		<img src="/assets/images/icon_xinyue.jpg" height="13px" width="16px" />心悦会员
		<img src="/assets/images/icon_vip.png"/>VIP会员
		&nbsp;有红色外边框代表未激活
		</span>
		</p>
	</div>
	<div class="content">
		<div >
			<a class="btn btn_sm" href="/team" style="clear:none;float:left;">回到顶层</a>
		    <a class="btn btn_sm" style="clear:none;float:right;" href="javascript:void(0);" onclick="javascript:history.back(-1);">返回</a>
		</div>
	<div id="cy" style="position:absolute;float:left;clear:left;">
		<script type="text/javascript" th:inline="javascript">
	    var data = [[${node}]];
	    console.log(data);
	    data = JSON.parse(data);
	    //console.log(data);
	    var rootNode = new OrgNode();
	    function start(){
	    		//第一层
	    		rootNode = addNode(rootNode,data);
		    /* 	rootNode.customParam.EmpName = data.info.name;
		    	rootNode.customParam.department = data.info.username;
		    	rootNode.customParam.userId = data.info.userId; */
		    	setPhoto(rootNode,data.info.memberLevel);
		    	//第一层左边
		    	var leftInfo = data.left;
		    	if(leftInfo != null){
		    		var lNode = addNode(rootNode,leftInfo);
		    		setPhoto(lNode,leftInfo.info.memberLevel);
		    		//第二层 左边
		    		var info_1_l = leftInfo.left;
		    		if(info_1_l != null){
		    			var node_1_l = addNode(lNode,info_1_l);
		    			setPhoto(node_1_l,info_1_l.info.memberLevel);
		    		}else{
			    		addEmptyNode(lNode);
			    	}
		    		//第二层 右边
		    		var  info_r_1= leftInfo.right;
		    		if(info_r_1 != null){
		    			var node_r_1 = addNode(lNode,info_r_1);
		    			setPhoto(node_r_1,info_r_1.info.memberLevel);
		    		}else{
			    		addEmptyNode(lNode);
			    	}
		    	}else{
		    		addEmptyNode(rootNode);
		    	}
		    	//第一层右边
		    	var rightInfo = data.right;
		    	if(rightInfo != null){
		    		var rNode = addNode(rootNode,rightInfo);
		    		setPhoto(rNode,rightInfo.info.memberLevel);
		    		//第二层 左边
		    		var info_1_l = rightInfo.left;
		    		if(info_1_l != null){
		    			var node_1_l = addNode(rNode,info_1_l);
		    			setPhoto(node_1_l,info_1_l.info.memberLevel);
		    		}else{
			    		addEmptyNode(rNode);
			    	}
		    		//第二层 右边
		    		var  info_r_1= rightInfo.right;
		    		if(info_r_1 != null){
		    			var node_r_1 = addNode(rNode,info_r_1);
		    			setPhoto(node_r_1,info_r_1.info.memberLevel);
		    		}else{
			    		addEmptyNode(rNode);
			    	}
		    	}else{
		    		addEmptyNode(rootNode);
		    	}
	    }

	    function addNode(node,info){
	    		var subNode = new OrgNode();
	    		subNode.customParam.EmpName = info.info.username;
	    		subNode.customParam.department = info.info.name;
	    		subNode.customParam.userId = info.info.userId;
	    		if(info.info.agentLevel != null){
	    			var agentName = '';
	    			if(info.info.agentLevel == 1){
	    				agentName = '代理';
	    			}else if(info.info.agentLevel == 2){
	    				agentName = '初级合伙人';
	    			}else if(info.info.agentLevel == 3){
	    				agentName = '中级合伙人';
	    			}else if(info.info.agentLevel == 4){
	    				agentName = '高级合伙人';
	    			}else if(info.info.agentLevel == 5){
	    				agentName = '联合创始人';
	    			}
	    			subNode.customParam.agentName = agentName;
	    		}else{
	    			subNode.customParam.agentName = "";
	    		}
	    		if(info.info.activeTime == null){
	    			subNode.customParam.style = "border:1px red solid;";
	    		}
	    		subNode.customParam.userId = info.info.userId;
	    		node.Nodes.Add(subNode);
	    		return subNode;
	    }

	    function addEmptyNode(node){
			var subNode = new OrgNode();
			subNode.customParam.EmpName = '空置';
			subNode.customParam.department = '';
			subNode.customParam.EmpPhoto = "img/none.png";
			subNode.customParam.agentName = "";
			node.Nodes.Add(subNode);
			return subNode;
	    }

	    function setPhoto(node,memberLevel){
	    		if(memberLevel == 1){
	    			node.customParam.EmpPhoto = "/assets/img/rel_1.png";
	    		}
	    		if(memberLevel == 2){
	    			node.customParam.EmpPhoto = "/assets/img/rel_2.png";
	    		}
	    		if(memberLevel == 3){
	    			node.customParam.EmpPhoto = "/assets/img/rel_VIP.png";
	    		}
	    		if (memberLevel == 4) {
                    node.customParam.EmpPhoto = "/assets/images/icon_xinyue.jpg";
				}
	    }
	    start();
		var OrgShows = new OrgShow(rootNode);
		OrgShows.Top = 50;
		OrgShows.Left = 50;
		OrgShows.IntervalWidth = 10;
		OrgShows.IntervalHeight = 20;
		//OrgShows.ShowType=2;
		//OrgShows.BoxHeight=100;
		OrgShows.BoxTemplet = "<div id=\"{Id}\" class=\"OrgBox\" onclick=\"CookieGroup('{userId}')\"><img src=\"{EmpPhoto}\" style=\"{style}\"/><span>{EmpName}</span><div>{department}</div><div class=\"agentName\">{agentName}</div></div>"
		OrgShows.Run();
		function CookieGroup(userId){
			if(userId != '{userId}'){
				window.location.href="team?userId="+userId;
			}
		}
		</script>
		</div>
	</div>
	<script language="javascript" type="text/javascript" src="/assets/javascript/jquery-2.1.4.min.js"></script>
</body>
</html>
